package com.ruoyi.common.enums.base;

/**
 * @ClassName PaymentStatus
 * @Description TODO
 * @Author Mr、Liu
 * @Date 2025/7/3 18:26
 * @Version 1.0
 */
/**
 * 支付状态枚举
 */
public enum PaymentStatus {

    /** 待支付 */
    PENDING(0, "待支付"),

    /** 支付成功 */
    SUCCESS(1, "支付成功"),

    /** 支付失败 */
    FAILED(2, "支付失败"),
    /** 支付中 */
    PROCESSING(3, "支付中");
    ;

    private final int code;
    private final String desc;

    PaymentStatus(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 根据 code 获取枚举
     */
    public static PaymentStatus of(int code) {
        for (PaymentStatus status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的支付状态码: " + code);
    }
}